-- -- -- -- -- -- --
-- -- MENU  -- -- --
-- -- -- -- -- -- --
-- TODO: cant load 'image' hooo?

-- 'sp' is the abbreviation of skillpoints

menu = {}

menu.sp = {}

menu.sp.image = "resources/sps.png"
if ENGINE == 1 then
menu.sp.x = 4
menu.sp.y = 4
menu.sp.width = 4
menu.sp.height = 4
elseif ENGINE == 2 then
--menu.sp.x = (SCREEN_WIDTH - Image.width(menu.sp.image))/ 2
--menu.sp.y = (SCREEN_HEIGHT - Image.height(menu.sp.image))/ 2
--menu.sp.width = Image.height(menu.sp.image)
--menu.sp.height = Image.width(menu.sp.image)
end

function menu.sp.screen() -- Function zum anzeigen des Menus,
	screen.blit (SCREEN_DOWN, menu.sp.x, menu.sp.y, spimg)
	screen.print(SCREEN_DOWN, menu.sp.x,menu.sp.y, hero.skp)
	screen.print(SCREEN_DOWN, menu.sp.x +104,menu.sp.y +11, hero.str)
	screen.print(SCREEN_DOWN, menu.sp.x +104,menu.sp.y +28, hero.agi)
	screen.print(SCREEN_DOWN, menu.sp.x +104,menu.sp.y +46, hero.int)
	screen.print(SCREEN_DOWN,menu.sp.x + 104,menu.sp.y +64, hero.dex)
	if Keys.newPress.B then game.status = 1 end
	if hero.skp > 0 then menu.sp.control() end

end

function menu.sp.control()
	if Stylus.released then
	sty = {}
	sty.x = Stylus.X
	sty.y = Stylus.Y
		if sty.x > menu.sp.x + 132 and sty.x < menu.sp.x + 144 then
			if sty.y > menu.sp.y + 12 and sty.y < menu.sp.y + 12 then hero.str  = hero.str + 1 hero.skp = hero.skp -1 end
			if sty.y > menu.sp.y + 30 and sty.y < menu.sp.y + 42 then hero.agi  = hero.agi + 1 hero.skp = hero.skp -1 end
			if sty.y > menu.sp.y + 48 and sty.y < menu.sp.y + 50 then hero.int  = hero.int + 1 hero.skp = hero.skp -1 end
			if sty.y > menu.sp.y + 67 and sty.y < menu.sp.y + 79 then hero.dex  = hero.dex + 1 hero.skp = hero.skp -1 end
			sty.x = 0
			sty.y = 0			
		end
	end
end
